package com.telit.android.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.telit.common.entity.SysOperationLog;
import com.telit.firecommand.vo.FireStatusTraceVO;
import com.telit.firecommand.vo.OperationDetailVO;
import com.telit.firecommand.vo.OperationVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * 系统操作日志DAO
 *
 * @author yuezhuang
 * @date 2022-09-19
 */
@Repository
public interface SysOperationLogDAO extends BaseMapper<SysOperationLog> {

    @Select("SELECT   oper_time as operTime,  " +
            "  business_id as fireId,  " +
            "   business_operator_type as businessOperatorType," +
            "  business_status as status, " +
            "  description as description  FROM sys_operation_log  WHERE business_id = #{fireId}  ORDER BY business_status ASC, oper_time DESC")
    List<OperationVO> fireOperatorLog(@Param("fireId") String fireId);


    @Select("SELECT   oper_time as operTime, " +
            "   dept_name as userCompany," +
            "   oper_name as userName,  " +
            "   oper_time as operTime,  " +
            "   business_id as fireId,  " +
            "   business_operator_type as businessOperatorType," +
            "   business_operator_type_name as businessOperatorTypeName," +
            "   business_status as status," +
            "   remark as remark," +
            "   description as description " +
            "   FROM sys_operation_log  WHERE business_id = #{fireId} and business_status=#{businessStatus} and error_msg is null ORDER BY  oper_time asc")
    List<OperationDetailVO> fireOperatorDetailLog(@Param("fireId") String fireId,
                                                  @Param("businessStatus") Integer businessStatus);


    @Select("SELECT   oper_time as operTime,  " +
            "  business_id as fireId,  " +
            "   business_operator_type as businessOperatorType," +
            "  business_status as status, " +
            "  description as description  FROM sys_operation_log  WHERE business_id = #{fireId} and business_status=#{businessStatus} and business_operator_type=#{businessOperatorType} and error_msg is null  ")
    OperationVO fireOperatorLogJj(@Param("fireId") String fireId, @Param("businessStatus") Integer businessStatus,
                                  @Param("businessOperatorType") Integer businessOperatorType);


    @Select("SELECT  oper_time AS handleTime, " +
            " oper_name AS userName, " +
            " dept_name AS userCompany, " +
            " remark AS remark, " +
            " business_id AS fireId, " +
            " business_operator_type AS businessOperatorType, " +
            " business_status AS alarmsStatus, " +
            " description AS description  FROM sys_operation_log  WHERE business_id = #{fireId}  and business_operator_type  in(11,25,26,34)  ORDER BY business_status ASC, oper_time DESC")
    List<FireStatusTraceVO> fireOperatorLogByFireId(@Param("fireId") String fireId);

}
